using System.Collections.Generic;
using FytSoa.Domain.Core.Jwt;
using FytSoa.Domain.Core.Jwt.Model;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace FytSoa.ApiService.Controllers
{
    [Route("[controller]")]
    public class TokenController : ApiController
    {
        [HttpGet ("token")]
        public IEnumerable<string> Get (string role) {
            var token = JwtAuthService.IssueJwt (new JwtToken () { Id = 123456, FullName = "张三", Role = role });
            return new string[] { token };
        }
        
        [HttpGet ("gettoken"), AllowAnonymous]
        public IActionResult GetToken (string token) {
            var resToken = JwtAuthService.SerializeJwt(token);
            return Ok (resToken);
        }
        
        [HttpGet ("Admin")]
        [Authorize]
        public IEnumerable<string> GetAdmin () {
            return new string[] {  "Adminsss" };
        }

        [HttpGet ("App")]
        [Authorize ("App")]
        public IEnumerable<string> GetApp () {
            return new string[] { "App" };
        }
    }
}